import React,{useEffect,useState} from 'react'
import * as echarts from 'echarts';
import { GET_STUDENT } from '../../api/student';
type EChartsOption = echarts.EChartsOption;
function LinteCom() {
  const [place,setPlace]=useState<string[]>([])
  useEffect(()=>{
      GET_STUDENT().then((res: any)=>{
        console.log(res);
        setPlace(res.data.data.result.legend)
        console.log(res.data.data.result);
        console.log(place);
        
      })
    var chartDom = document.getElementById('obtain')!;
var myChart = echarts.init(chartDom);
var option: EChartsOption;

option = {
  tooltip: {
    trigger: 'axis',
    axisPointer: {
      type: 'shadow'
    }
  },
  legend: {},
  grid: {
    left: '3%',
    right: '4%',
    bottom: '3%',
    containLabel: true
  },
  xAxis: {
    type: 'value',
    boundaryGap: [0, 0.01]
  },
  yAxis: {
    type: 'category',
    data: ['Brazil', 'Indonesia', 'USA', 'India', 'China', 'World']
  },
  series: [
    {
      name: '2011',
      type: 'bar',
      data: [18203, 23489, 29034, 104970, 131744, 630230]
    },
    {
      name: '2012',
      type: 'bar',
      data: [19325, 23438, 31000, 121594, 134141, 681807]
    }
  ]
};

option && myChart.setOption(option);

  },[])
  return (
     <div id="obtain" style={{width: '22vw',height:'35vh'}}></div>
  )
}

export default LinteCom
